/* This code is restricted under LGPL license */
using NHibernate.Criterion;

namespace infoMECHANICA.NHibernateORM.CriteriaBuilder
{
    /// <summary>
    /// Base class for criterion properties
    /// </summary>
    /// <typeparam name="T">Base property type</typeparam>
    public class CriterionPropertyBase<T> : PropertyNameHolder, ICriterionSource
    {
        private ICriterion savedCriterion;

        /// <summary>
        /// Saved criterion value (after set... methods calls)
        /// </summary>
        protected ICriterion SavedCriterion
        {
            get { return savedCriterion; }
            set { savedCriterion = value; }
        }

        /// <summary>
        /// Constructor, sets PropertyName
        /// </summary>
        /// <param name="propertyName">PropertyName to set</param>
        public CriterionPropertyBase(string propertyName)
            : base(propertyName)
        {
        }

        #region ICriterionSource Members

        /// <summary>
        /// <see>ICriterionSource</see> interface summary
        /// </summary>
        public virtual ICriterion GetCriterion()
        {
            return this.SavedCriterion;
        }

        #endregion
    }
}
